<template>
  <div class="app-container">
    <el-dialog
      title="选择设备"
      :visible.sync="dialogTableVisible"
      :close-on-click-modal="false"
      :before-close="close"
      width="900px">
    <el-form :model="selectForm" ref="queryForm" :inline="true">
      <el-form-item label="设备编号：">
        <el-input size="small" v-model="selectForm.deviceId" placeholder="请输入设备编号" clearable/>
      </el-form-item>
      <el-form-item label="设备名称：">
        <el-input size="small" v-model="selectForm.deviceName" placeholder="请输入设备名称" clearable/>
      </el-form-item>
      <el-form-item label="设备状态：">
        <el-select v-model="selectForm.status" placeholder="请选择">
          <el-option
            v-for="item in deviceStatus"
            :key="item.label"
            :label="item.label"
            :value="item.label">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="所属部门：">
        <department></department>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" type="primary" icon="el-icon-search">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="list" border  @selection-change="currentChange">
      <el-table-column type="selection" width="55" />
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column align="center" label="设备编号" prop="deviceId" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="设备名称" prop="deviceName" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="设备品牌" prop="deviceBrand" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="规格型号" prop="deviceModel"/>
      <el-table-column align="center" label="状态">
        <template slot-scope="scope">
          <template v-if="scope.row.status==1">是</template>
          <template v-if="scope.row.status==2">否</template>
        </template>
      </el-table-column>
      <el-table-column align="center" label="所属部门" prop="department"/>
    </el-table>
    <pagination
      :total="total"
      :page.sync="selectForm.pageNum"
      :limit.sync="selectForm.pageSize"
      @pagination="getList"
    />
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="$emit('selectChange')">取消</el-button>
        <el-button size="mini" @click="submit">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import department from "./department";
  export default {
    name: "addDialog.vue",
    components:{
      department
    },
    data() {
      return {
        dialogTableVisible:true,
        loading: false,//加载
        selectForm: {
          deviceId: '',//设备编号
          deviceName: '',//设备名称
          deviceBrand: '',//
          deviceModel: '',//
          status: '',//
          plan:'',
          pageNum: 1,
          pageSize: 10,
        },//查询条件
        list: [
          {
            deviceId: 'CGJH2020000265',
            deviceName: '测试',
            deviceBrand: '测试',
            deviceModel: '测试',
            status: 1,
            department:'设备部'
          },
          {
            deviceId: 'CGJH2020000265',
            deviceName: '测试',
            deviceBrand: '测试',
            deviceModel: '测试',
            status: 1,
            department:'设备部'
          }
        ],//数据
        total: 2,
        selectDate: '',//时间
        deviceStatus:[{
          value:'',
          label:'保养',
        },{
          value:'',
          label:'闲置',
        },{
          value:'',
          label:'在用',
        },{
          value:'',
          label:'预转固',
        },{
          value:'',
          label:'故障',
        },{
          value:'',
          label:'正常',
        }],
        selectData:'',
      }
    },
    created() {
    },
    methods: {
      getList() {

      },
      close(){
        this.$emit('selectChange')
      },
     currentChange(val){
        this.selectData=val
      },
      submit(){
        if(this.selectData){
          this.$emit('selectChange',this.selectData)
        }
      }
    }
  }
</script>

<style scoped>
  .bule {
    color: #2196F3;
    cursor: pointer
  }
</style>
